package com.ebuy.api.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ebuy.api.domain.TbRole;
import com.ebuy.api.mapper.TbRoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: ren.zhong@chebada.com
 * @date: 2023年09月12日10:56:52
 **/
@Service
public class RoleService extends ServiceImpl<TbRoleMapper, TbRole> {

    @Autowired
    TbRoleMapper tbRoleMapper;

    public boolean setStatus(Integer status,Integer id){
        LambdaQueryWrapper<TbRole> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TbRole::getId, id);
        List<TbRole> list=super.list(wrapper);
        list.forEach(u->u.setStatus(status));
        return super.updateBatchById(list);
    }

    public List<TbRole> getByIdList(List<Integer> IdList) {
        LambdaQueryWrapper<TbRole> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(TbRole::getId, IdList);
        return super.list(wrapper);
    }

}